package com.qidian.mes.produce.controller;

import com.qidian.common.pojo.MESResult;
import com.qidian.mes.pojo.Material;
import com.qidian.mes.pojo.WorkOrder;
import com.qidian.mes.produce.service.WorkOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author 陈俊成
 * @Company ccc
 * @Description
 * @Time 2024/10/23 16:33
 */
@RestController
@RequestMapping("/workOrder")
@CrossOrigin
public class WorkOrderController {
    @Autowired
    WorkOrderService workOrderService;
    @GetMapping("/list")
    public MESResult queryList(WorkOrder workOrder, @RequestParam(defaultValue = "1")int page, @RequestParam(defaultValue = "10")int limit){
        return workOrderService.queryList(workOrder,page,limit);
    }

    @PostMapping("/add")
    public MESResult add(@RequestBody WorkOrder workOrder){
        return workOrderService.addWorkOrder(workOrder);
    }

    @GetMapping("/getPrimary")
    public MESResult getPrimary(int workOrderRelId){
        return workOrderService.getPrimary(workOrderRelId);
    }

    @PutMapping("/primary")
    public MESResult primary(@RequestBody WorkOrder workOrder){
        System.out.println("+++++++++++++++++++++++++++++++++++++++++++++++"+workOrder);
        return workOrderService.primary(workOrder);}

    @PutMapping("/primarySure")
    public MESResult primarySure(@RequestBody WorkOrder workOrder){return workOrderService.surePrimary(workOrder);}

    @DeleteMapping("/delete")
    public MESResult delete(int workOrderRelId){
        return workOrderService.deleteWorkOrder(workOrderRelId);
    }

    @PostMapping("/deleteAll")
    public MESResult deleteAll(@RequestBody List<WorkOrder> workOrders){
        return workOrderService.deleteWorkOrders(workOrders);
    }

}
